import React, {createRef, forwardRef} from 'react'
import { connect } from 'react-redux'

// import { loginAction } from './redux/action/loginAction'
import TestStick from '../test/index'
import Navigation from './react-navigation/index'
import AppIntro from './TestAppIntro'

export let Navigator = createRef()
const BaseNavRoot = forwardRef((props, ref) => (
  <Navigation ref={ref} />
))

class Root extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      isShowAppIntro: false,
    }
  }

  componentDidMount() {
    TestStick.show()
    console.log('isLogin=', this.props.isLogin)
  }

  render = () => {
    if (this.state.isShowAppIntro) {
      return <AppIntro onPress={this._enterMain} />
    } else {
      return <BaseNavRoot />
    }
  }

  _enterMain = () => {
    this.setState({ isShowAppIntro: false })
  }
}

const mapStateToProps = (state) => ({
  isLogin: state.loginReducer.isLogin,
})

const mapStateToDispatch = {
  // loginAction,
}
export default connect(mapStateToProps, mapStateToDispatch)(Root)
